const vm = new Vue({
    el:'#app',
    data:{
        foodList:[],
        number:"0",
        money:0
    },
    created:function(){
        fetch('http://127.0.0.1:5500/elm_demo/api/bought.json').then(function(res){
            return res.json();
        }).then(function(data){
            vm.foodList = data;
        })
    },
    methods: {
        add(id,price){
            this.foodList[id].num++;
            this.number++;
            this.money += price;
        },
        reduce(id,price){
            this.foodList[id].num--;
            this.number--;
            this.money -= price;
        }
    }
})
